package core.obj;

import javafx.util.Pair;

import java.util.Vector;

public abstract class Sort<T> {
    protected Comparable<T>[] arr;
    protected Comparable<T>[] reverseArr;
    protected Vector<Pair<Integer,Integer>> process;//交换过程
    protected Vector<Pair<Integer,Integer>> pointers;//指针过程

    public Sort(Comparable<T>[] arr){
        this.arr =arr;
        process=new Vector<>();
        pointers=new Vector<>();
        sort();
       revrse();
    }

    public Comparable<T>[] getSortResult() {
        return arr;
    }

    public Vector<Pair<Integer,Integer>> getProcess() {
        return process;
    }

    public Vector<Pair<Integer, Integer>> getPointers() {
        return pointers;
    }

    protected void revrse(){
        reverseArr=new Comparable[arr.length];
        int j = 0;
        for(int i = arr.length-1;i>=0;i--){
            reverseArr[i] = arr[j];
            j++;
        }
    }

    public Comparable<T>[] getReverseSortResult() {
        return reverseArr;
    }

    public abstract void sort();
}
